package xx.iverson.navigation_manager.util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.context.annotation.Configuration;

/**
 * xx.iverson.navigation_manager.WebMvcConfig.WebMvcConfig
 * 描述：
 * on 2025/9/11-下午4:25
 *
 * @author weijx
 */

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 映射D盘的navigation_image文件夹到URL的/image路径
        registry.addResourceHandler("/image/**")
                .addResourceLocations("file:D:/navigation_image/");
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册自定义的拦截器，并排除静态资源和登录页面
        registry.addInterceptor(new LoginRequiredInterceptor())
                .excludePathPatterns("/")
                .excludePathPatterns("/admin/login")
                .excludePathPatterns("/login")
                .excludePathPatterns("/resources/**", "/static/**", "/css/**", "/js/**", "/webjs/**", "/img/**", "/image/**");
    }
}
